package com.rayson.yututu.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author: rayson
 * Description: 空间级别枚举类
 * Date: 2025-01-11 11:23
 */
@Getter
@AllArgsConstructor
public enum SpaceLevelEnum {

    COMMON("普通版", 0, 100L, 100L * 1024 * 1024),
    PRO("专业版", 1, 1000L, 1000L * 1024 * 1024),
    FLAGSHIP("旗舰版", 2, 10000L, 1000L * 1024 * 1024),
    ;

    private static final Map<Integer, SpaceLevelEnum> cache;

    static {
        cache = Arrays.stream(SpaceLevelEnum.values()).
                collect(Collectors.toMap(SpaceLevelEnum::getValue, Function.identity()));
    }

    private final String name;
    private final Integer value;
    private final Long maxCount;
    private final Long maxSize;

    public static SpaceLevelEnum getEnumByValue(Integer value) {
        return cache.get(value);
    }

    public static Boolean isCommon(Integer value) {
        return SpaceLevelEnum.COMMON.getValue().equals(value);
    }

}
